//
//  ThirdPerson_Company.m
//  HappyStore
//
//  Created by 点点充 on 16/1/29.
//  Copyright © 2016年 LLJ. All rights reserved.
//

#import "ThirdPerson_Company.h"

@interface ThirdPerson_Company ()
{
    NSMutableDictionary *dicData;
    
    NSInteger seleType;//选择的哪个类型
    
    
    NSArray *aryTitle1;
    NSMutableArray *muAryTitleContent;
    
    NSMutableArray *muAryWork;//工作经历
    NSMutableArray *muAryEducation;//教育经历
    NSMutableArray *muAryHobby;//兴趣爱好
    NSMutableArray *muAryGoodatfield;//擅长领域
    NSMutableArray *muAryMyneeds;//我的需求
    
    UIImage *imgUserHeaderImg;//用户头像
    UIButton *btnHeader;
    UIButton *btnUserName;//用户名称
    
    UIView *_slideView;
    
    BOOL isFirstAddSlide;
    
    NSInteger paggge;
    
    NSMutableArray *muAryData;
    
    UIButton *btnLove;
    
    NSArray *TopPhotos;
}

@end

@implementation ThirdPerson_Company

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = self.strUserName;
    
    self.btnPhone.layer.masksToBounds = YES;
    self.btnPhone.layer.cornerRadius = 5.f;
    
    self.btnMessage.layer.masksToBounds = YES;
    self.btnMessage.layer.cornerRadius = 5.f;
    
    seleType = 0;//概况
    
    [self startPostNetWorkInfo];
    
    _mainTableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        paggge += 1;
        [self startSearch];
    }];
    _mainTableView.mj_footer.hidden = YES;
    
    //开启侧滑
    self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
    
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (seleType == 0) {
        return 5;
    }else {
        return muAryData.count+1;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return 220;
    }
    else {
        if (seleType == 0) {
            if (indexPath.row < aryTitle1.count+1) {//个人信息
                return 44;
            }else if (indexPath.row == aryTitle1.count+1) {//企业简介
                CGSize size1 = CGSizeMake(0, 0);
                if (dicData[@"introduction"] == [NSNull null] || [dicData[@"introduction"] isEqualToString:@"null"]) {
                    
                    return 51+158*TopPhotos.count+8;
                }else {
                    size1 = [LLJLabelHeight UIlabelGetFont:16.f sizeWidth:300 strNeirong:dicData[@"introduction"]];
                    return size1.height+51+158*TopPhotos.count+8;
                }
            }else {
                return 44;
            }
        }else if(seleType == 5){//招聘
            return 120;
        }else {
            return 110;
        }
    }
    
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellHeader = @"cellHeader";//头像
    static NSString *cellSex = @"cellSex";//信息
    static NSString *cellTitle = @"cellTitle";//标题
    
    static NSString *cell2 = @"cell2";//项目
    static NSString *cell3 = @"cell3";//求职
    
    UITableViewCell *cell;
    
    if (indexPath.row == 0) {
        cell = [tableView dequeueReusableCellWithIdentifier:cellHeader forIndexPath:indexPath];
        //头像
        btnHeader = [cell viewWithTag:10];
        btnHeader.layer.masksToBounds = YES;
        btnHeader.layer.cornerRadius = 35;
        [btnHeader setImage:nil forState:UIControlStateNormal];
        [btnHeader sd_setBackgroundImageWithURL:[NSURL URLWithString:dicData[@"headPhoto"]] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"btn_my_touxiang"]];
//        [btnHeader sd_setImageWithURL:[NSURL URLWithString:dicData[@"headPhoto"]] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"btn_my_touxiang"]];
        
        UIImageView *imgVip = [cell viewWithTag:11];
        if ([dicData[@"vipLevel"] integerValue] == 0) {
            imgVip.image = [UIImage imageNamed:@"img_my_vip2"];
        }else {
            imgVip.image = [UIImage imageNamed:@"img_my_vip1"];
        }
        //名称
        btnUserName = [cell viewWithTag:12];
        if (dicData[@"username"] == [NSNull null] || [dicData[@"username"] isEqualToString:@"null"]) {
            [btnUserName setTitle:dicData[@"account"] forState:UIControlStateNormal];
        }else {
            [btnUserName setTitle:dicData[@"username"] forState:UIControlStateNormal];
        }
        
        if (!isFirstAddSlide) {
            _topScrollView = [[UIScrollView alloc] initWithFrame:(CGRect){0,166,320,50}];
            [cell addSubview:_topScrollView];
            [self addTopButton];
            isFirstAddSlide = YES;
        }
        
        //粉丝
        btnLove = [cell viewWithTag:20];
        btnLove.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6f];
        btnLove.layer.masksToBounds = YES;
        btnLove.layer.cornerRadius = 8.0f;
        [btnLove setTitle:[NSString stringWithFormat:@"%@",dicData[@"focusNumber"]] forState:UIControlStateNormal];
        if ([dicData[@"isFocus"] isEqualToString:@"否"]) {
            [btnLove setImage:[UIImage imageNamed:@"project_detail_taoxin_normal"] forState:UIControlStateNormal];
        }else {
            [btnLove setImage:[UIImage imageNamed:@"project_detail_taoxin_pressed"] forState:UIControlStateNormal];
        }
        [btnLove addTarget:self action:@selector(btnClickLove) forControlEvents:UIControlEventTouchUpInside];
        
    }
    
    else {
        
        if (seleType == 0) {
            if (indexPath.row <aryTitle1.count+1) {//个人信息
                cell = [tableView dequeueReusableCellWithIdentifier:cellSex forIndexPath:indexPath];
                
                UILabel *labTitle = [cell viewWithTag:10];
                labTitle.text = aryTitle1[indexPath.row-1];
                
                UILabel *labContent = [cell viewWithTag:11];
                labContent.text = muAryTitleContent[indexPath.row-1];
                
            }else {
                //企业简介
                cell = [tableView dequeueReusableCellWithIdentifier:cellTitle forIndexPath:indexPath];
                CGSize size1 = CGSizeMake(0, 51);
                if (dicData[@"introduction"] == [NSNull null] || [dicData[@"introduction"] isEqualToString:@"null"]) {
                    for (int i = 0; i<TopPhotos.count; i++) {
                        UIImageView *img = [[UIImageView alloc] initWithFrame:(CGRect){10,(size1.height)+158*i,300,150}];
                        [img sd_setImageWithURL:[NSURL URLWithString:TopPhotos[i]] placeholderImage:[UIImage imageNamed:@"img_normal1"]];
                        [cell addSubview:img];
                    }
                    
                }else {
                    UILabel *labContent = [[UILabel alloc] init];
                    size1 = [LLJLabelHeight UIlabelGetFont:16.f sizeWidth:300 strNeirong:dicData[@"introduction"]];
                    labContent.frame = (CGRect){10,51,300,size1.height};
                    labContent.text = dicData[@"introduction"];
                    labContent.font = [UIFont systemFontOfSize:16.f];
                    labContent.textColor = [UIColor colorWithRed:89/255.0f green:87/255.0f blue:87/255.0f alpha:1.0f];
                    labContent.numberOfLines = 0;
                    [cell addSubview:labContent];
                    
                    for (int i = 0; i<TopPhotos.count; i++) {
                        UIImageView *img = [[UIImageView alloc] initWithFrame:(CGRect){10,(labContent.frame.origin.y + labContent.frame.size.height + 8)+158*i,300,150}];
                        [img sd_setImageWithURL:[NSURL URLWithString:TopPhotos[i]] placeholderImage:[UIImage imageNamed:@"img_normal1"]];
                        [cell addSubview:img];
                    }
                    
                }
            }
            
        }
        else if (seleType == 5) {//求职
            BOOL nibsRegistered2 = NO;
            if (!nibsRegistered2) {
                UINib *nib=[UINib nibWithNibName:@"TableViewCell3" bundle:nil];
                [tableView registerNib:nib forCellReuseIdentifier:cell3];
                nibsRegistered2=YES;
            }
            
            NSLog(@"%ld",indexPath.row);
            cell = [tableView dequeueReusableCellWithIdentifier:cell3];
            UIView *viewBack = [cell viewWithTag:50];
            viewBack.layer.masksToBounds = YES;
            viewBack.layer.borderColor = [UIColor colorWithWhite:0.8 alpha:1.0f].CGColor;
            viewBack.layer.borderWidth = 0.5f;
            
            
            UIImageView *imgHeader = [cell viewWithTag:51];
            [imgHeader sd_setImageWithURL:[NSURL URLWithString:muAryData[indexPath.row-1][@"headPhoto"]] placeholderImage:[UIImage imageNamed:@"img_normal3"]];
            imgHeader.layer.masksToBounds = YES;
            imgHeader.layer.cornerRadius = 23.f;
            
            UILabel *labUserName = [cell viewWithTag:52];
            if (muAryData[indexPath.row-1][@"username"] == [NSNull null] || [muAryData[indexPath.row-1][@"username"] isEqualToString:@"null"]) {
                labUserName.text = muAryData[indexPath.row-1][@"account"];
            }else {
                labUserName.text = muAryData[indexPath.row-1][@"username"];
            }
            
            //进用户详情
            UIButton *btnHeader = [cell viewWithTag:53];
            
            UILabel *labTitle = [cell viewWithTag:10];
            labTitle.text = muAryData[indexPath.row-1][@"title"];
            
            //薪资
            UILabel *labPrice = [cell viewWithTag:11];
            labPrice.text = [CustomExcetion comperNumber:muAryData[indexPath.row-1][@"money"]];
            
            //经验
            UILabel *labExperience = [cell viewWithTag:12];
            labExperience.text = muAryData[indexPath.row-1][@"experience"];
            
            //学历
            UILabel *labDegree = [cell viewWithTag:13];
            labDegree.text = muAryData[indexPath.row-1][@"schooling" ];
            
            //职位
            UILabel *labPosition = [cell viewWithTag:14];
            labPosition.text = muAryData[indexPath.row-1][@"positionName"];
            
            //行业
            UILabel *labIndustry = [cell viewWithTag:15];
            labIndustry.text = muAryData[indexPath.row-1][@"industry"];
            
            //发布时间
            UILabel *labReleaseDate = [cell viewWithTag:16];
            labReleaseDate.text = [CustomExcetion prettyDateWithReference:[CustomExcetion dateFromString:muAryData[indexPath.row-1][@"createTime"]]];
            
            //工作地点
            UILabel *labWorkPlace = [cell viewWithTag:17];
            labWorkPlace.text = muAryData[indexPath.row-1][@"addresss"];
            
            
        }
        
        else {
            BOOL nibsRegistered3 = NO;
            if (!nibsRegistered3) {
                UINib *nib=[UINib nibWithNibName:@"TableViewCell2" bundle:nil];
                [tableView registerNib:nib forCellReuseIdentifier:cell2];
                nibsRegistered3=YES;
            }
            
            NSLog(@"%ld",indexPath.row);
            cell = [tableView dequeueReusableCellWithIdentifier:cell2];
            
            UIButton *btn = [cell viewWithTag:10];//lable
            btn.userInteractionEnabled = NO;
            if (muAryData[indexPath.row-1][@"lable"] == [NSNull null] || [muAryData[indexPath.row-1][@"lable"] isEqualToString:@"null"]) {
                btn.hidden = YES;
            }else {
                NSString *_string = muAryData[indexPath.row-1][@"lable"];
                NSArray *_arr = [_string componentsSeparatedByString:NSLocalizedString(@",", nil)];
                [btn setTitle:_arr[0] forState:UIControlStateNormal];
            }
            
            
            UIImageView *imgV = [cell viewWithTag:20];
            [imgV sd_setImageWithURL:[NSURL URLWithString:muAryData[indexPath.row-1][@"logo"]] placeholderImage:[UIImage imageNamed:@"img_normal3"]];
            imgV.layer.masksToBounds = YES;
            imgV.layer.cornerRadius = 5.f;
            
            UILabel *labTitle = [cell viewWithTag:21];
            labTitle.text = muAryData[indexPath.row-1][@"title"];
            
            UILabel *labPrice = [cell viewWithTag:22];
            labPrice.text = [CustomExcetion comperNumber:muAryData[indexPath.row-1][@"investment"]];
            
            UILabel *labAddress = [cell viewWithTag:23];
            labAddress.text = muAryData[indexPath.row-1][@"address"];
            
            UILabel *labPeople = [cell viewWithTag:24];
            if (muAryData[indexPath.row-1][@"username"] == [NSNull null] || [muAryData[indexPath.row-1][@"username"] isEqualToString:@"null"]) {
                labPeople.text = muAryData[indexPath.row-1][@"account"];
            }else {
                labPeople.text = muAryData[indexPath.row-1][@"username"];
            }
            
            
            UILabel *labDate = [cell viewWithTag:25];
            NSDate *date = [CustomExcetion dateFromString:muAryData[indexPath.row-1][@"createtime"]];
            labDate.text = [CustomExcetion prettyDateWithReference:date];
            
            
        }
    }
    
    
    return cell;
    
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];//取消选中状态
    
    //取消显示后退键文字
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
    self.navigationItem.backBarButtonItem = barButtonItem;
    
    switch (seleType) {
        case 1://项目
        {
            Project_Detail *project_detail = [self.storyboard instantiateViewControllerWithIdentifier:@"project_detail"];
            project_detail.projectId = muAryData[indexPath.row-1][@"projectId"];
            [self.navigationController pushViewController:project_detail animated:YES];
        }
            break;
        case 2://资金
        {
            SearchPrice_Detail *SearchPrice_Detail = [self.storyboard instantiateViewControllerWithIdentifier:@"SearchPrice_Detail"];
            SearchPrice_Detail.fundsId = muAryData[indexPath.row-1][@"fundsId"];
            [self.navigationController pushViewController:SearchPrice_Detail animated:YES];
        }
            break;
        case 3://活动
        {
            BusinessActivity_Detail *business_Detail = [self.storyboard instantiateViewControllerWithIdentifier:@"business_detail"];
            business_Detail.activityId = muAryData[indexPath.row-1][@"activityId"];
            [self.navigationController pushViewController:business_Detail animated:YES];
        }
            break;
        case 4://服务
        {
            SoftwareDevelop_Detail *SoftwareDevelop_Detail = [self.storyboard instantiateViewControllerWithIdentifier:@"SoftwareDevelop_Detail"];
            SoftwareDevelop_Detail.projectId = muAryData[indexPath.row-1][@"serviceId"];
            [self.navigationController pushViewController:SoftwareDevelop_Detail animated:YES];
        }
            break;
        case 5://求职
        {//type=类型 1招聘 2求职
            Recruitment_Detail *recruitment = [self.storyboard instantiateViewControllerWithIdentifier:@"recruitment_Detail"];
            recruitment.projectId = muAryData[indexPath.row-1][@"jobId"];
            //求职
            recruitment.strType = @"1";
            [self.navigationController pushViewController:recruitment animated:YES];
        }
            break;
    }
    
    
}


#pragma mark - 基本信息
- (void)startPostNetWorkInfo
{
    [self showRoundProgressWithTitle:@"请稍后..."];
    
    //token=rE3F2m8AvfC7CVh85O9q&userId=9&userType=用户类型 1-个人，2-企业，3-政府
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:self.strUserType forKey:@"userType"];//用户类型 1-个人，2-企业，3-政府
    [muDicParameters setObject:self.strUserId forKey:@"userId"];
//    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    if ([USER_DEFAULTS objectForKey:@"userid"] != nil) {
        [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"MyUserId"];
    }
    
    NSString *strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"MyBasicMessage_app_myHome.im"];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager POST:strURl parameters:muDicParameters progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
//        NSLog(@"%@",dicInfo);

        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
            dicData = [NSMutableDictionary dictionaryWithDictionary:dicInfo[@"data"]];
            
            NSMutableString *muStr = [NSMutableString string];
            BOOL isNull = NO;
            if (dicData[@"companyAccount"] == [NSNull null] || [dicData[@"companyAccount"] isEqualToString:@"null"]) {
                if (dicData[@"companyUserName"] == [NSNull null] || [dicData[@"companyUserName"] isEqualToString:@"null"] ) {
                    isNull = YES;
                }
                
            }else {
                if (dicData[@"companyUserName"] == [NSNull null] || [dicData[@"companyUserName"] isEqualToString:@"null"]) {
                    [muStr appendFormat:@"%@",dicData[@"companyAccount"]];
                }else {
                    [muStr appendFormat:@"%@",dicData[@"companyUserName"]];
                }
                
            }
            
            if (dicData[@"goveAccount"] == [NSNull null] || [dicData[@"goveAccount"] isEqualToString:@"null"]) {
                if (dicData[@"goveUserName"] == [NSNull null] || [dicData[@"goveUserName"] isEqualToString:@"null"]) {
                    if (isNull) {
                        [muStr appendString:@"无"];
                    }
                    
                }
            }else {
                if (dicData[@"goveUserName"] == [NSNull null] || [dicData[@"goveUserName"] isEqualToString:@"null"]) {
                    [muStr appendFormat:@"%@",dicData[@"goveAccount"]];
                }else {
                    [muStr appendFormat:@"%@",dicData[@"goveUserName"]];
                }
                
            }
            
            
            aryTitle1 = @[@"隶属组织:",@"联系方式:",@"所在地区:"];
            muAryTitleContent = [NSMutableArray arrayWithObjects:muStr,dicData[@"mobile"],dicData[@"address"], nil];
            
            TopPhotos = dicData[@"photoalbum"];
            
            
            
            [_mainTableView reloadData];
            
            [self hideBubble];

        }else {

            [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];

        }
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

        [self showSingleIconBubble:error.localizedDescription];

    }];
}



- (void)addTopButton
{
    NSArray *aryItem = @[@"概况",@"项目",@"资金",
                         @"活动",@"服务",@"招聘"];
    CGFloat width = 77;
    _topScrollView.showsHorizontalScrollIndicator = NO;
    _topScrollView.showsVerticalScrollIndicator = YES;
    _topScrollView.contentSize = CGSizeMake(78 * 6, 50);
    
    for (int i = 0; i < aryItem.count; i ++) {
        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(i * width, 0, width, 48)];
        button.tag = i;
        [button setTitle:aryItem[i] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(tabButton:) forControlEvents:UIControlEventTouchUpInside];
        [button setTitleColor:[UIColor colorWithRed:89/255.f green:87/255.f blue:87/255.f alpha:1.f] forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:15.f];
        [_topScrollView addSubview:button];
        
        UILabel *labH = [[UILabel alloc] initWithFrame:(CGRect){i*width+78,10,1,30}];
        labH.backgroundColor = [UIColor colorWithRed:170/255.f green:170/255.f blue:170/255.f alpha:1.f];
        [_topScrollView addSubview:labH];
        
    }
    
    [self initSlideView];
}


- (void)tabButton:(UIButton *)sender
{
    CGRect frame = _slideView.frame;
    frame.origin.x = sender.frame.origin.x;
    _slideView.frame = frame;
    
    seleType = sender.tag;
    //顶部跟着滑动
    [_topScrollView scrollRectToVisible:CGRectMake(sender.frame.origin.x-sender.frame.size.width*2, 0, _topScrollView.frame.size.width, _topScrollView.frame.size.height) animated:YES];
    paggge = 1;
    
    if (seleType != 0) {
        [self startSearch];
    }else {
        [self.mainTableView reloadData];
    }
    
}

#pragma mark -- 初始化滑动的指示View
-(void) initSlideView {
    
    CGFloat width = 80;
    
    _slideView = [[UIView alloc] initWithFrame:CGRectMake(0, 47, width, 3)];
    [_slideView setBackgroundColor:[UIColor colorWithRed:32/255.f green:165/255.f blue:240/255.f alpha:1.f]];
    [_topScrollView addSubview:_slideView];
}


#pragma mark - 获取数据 项目、
- (void)startSearch
{
    [self showRoundProgressWithTitle:@"请稍后..."];
    //token=验证用户&page=页码&userId=用户id
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:self.strUserId forKey:@"userId"];
//    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    [muDicParameters setObject:[NSString stringWithFormat:@"%ld",paggge] forKey:@"page"];
    
    NSString *strURl = @"";
    
    switch (seleType) {
        case 1://项目
        {
            strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getMyoutProject_app_myHome.im"];
        }
            break;
        case 2://资金
        {
            strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getMyoutFunds_app_myHome.im"];
        }
            break;
        case 3://活动
        {
            strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getMyoutActivity_app_myHome.im"];
            
        }
            break;
        case 4://服务
        {
            strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getMyoutService_app_myHome.im"];
        }
            break;
        case 5://招聘
        {//type=类型 1招聘 2求职
            [muDicParameters setObject:@"1" forKey:@"type"];
            strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getMyoutJobhunting_app_myHome.im"];
        }
            break;
    }
    
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager POST:strURl parameters:muDicParameters progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        [_mainTableView.mj_header endRefreshing];
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
//        NSLog(@"%@",dicInfo);

        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
            [_mainTableView.mj_header endRefreshing];
            if (paggge == 1) {
                muAryData = [NSMutableArray arrayWithArray:[dicInfo objectForKey:@"data"][@"record"]];
                
                if (muAryData.count == 10) {
                    _mainTableView.mj_footer.hidden = NO;
                }else {
                    _mainTableView.mj_footer.hidden = YES;
                }
                
            }else {
                NSArray *ary11 = [dicInfo objectForKey:@"data"][@"record"];
                for (int i = 0; i<ary11.count; i++) {
                    NSDictionary *dic1 = ary11[i];
                    [muAryData addObject:dic1];
                }
                if (ary11.count == 10) {
                    _mainTableView.mj_footer.hidden = NO;
                }else {
                    _mainTableView.mj_footer.hidden = YES;
                }
                
            }
            
            
            [_mainTableView reloadData];
            
            [self hideBubble];

        }else {
            if (paggge == 1) {
                muAryData = [NSMutableArray array];
            }
            
            [_mainTableView reloadData];
            [_mainTableView.mj_header endRefreshing];
            [_mainTableView.mj_footer endRefreshing];

            [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];

        }
        
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [_mainTableView.mj_header endRefreshing];
        [_mainTableView.mj_footer endRefreshing];
        if (paggge == 1) {
            muAryData = [NSMutableArray array];
            [_mainTableView reloadData];
        }

    }];
}

#pragma mark - 关注、取消
- (void)btnClickLove
{
    if ([USER_DEFAULTS objectForKey:@"userid"]!=nil) {

        NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
        //token=rE3F2m8AvfC7CVh85O9q&userId=登陆用户id&targetUuserIid=被关注用户的id
        
        [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
        [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
        [muDicParameters setObject:self.strUserId forKey:@"targetUuserIid"];//被关注用户的id
        NSString *strURl = @"";
        if ([dicData[@"isFocus"] isEqualToString:@"否"]) {
            strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"focusUser_app_myHome.im.lensum"];
        }else {
            strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"focusUser_cannel_app_myHome.im.lensum"];
        }
        
        AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        [manager POST:strURl parameters:muDicParameters progress:^(NSProgress * _Nonnull uploadProgress) {
            
        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
            
            NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
//            NSLog(@"%@",dicInfo);

            if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
                NSInteger focus = [dicData[@"focusNumber"] integerValue];
                if ([dicData[@"isFocus"] isEqualToString:@"否"]) {
                    focus += 1;
                    [btnLove setImage:[UIImage imageNamed:@"project_detail_taoxin_pressed"] forState:UIControlStateNormal];
                    [dicData setObject:@"是" forKey:@"isFocus"];
                }else {
                    focus -= 1;
                    [btnLove setImage:[UIImage imageNamed:@"project_detail_taoxin_normal"] forState:UIControlStateNormal];
                    [dicData setObject:@"否" forKey:@"isFocus"];
                }
                [dicData setObject:[NSString stringWithFormat:@"%ld",focus] forKey:@"focusNumber"];
                
                [btnLove setTitle:[NSString stringWithFormat:@"%ld",focus] forState:UIControlStateNormal];

                [self showRightWithTitle:[dicInfo objectForKey:@"msg"] autoCloseTime:2];
            }else {

                [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];
            }
            

        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

            [self showSingleIconBubble:error.localizedDescription];

        }];
    }else {
        //登录
        UIStoryboard *LoginAndRegister = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        UINavigationController *loginNAV = [LoginAndRegister instantiateViewControllerWithIdentifier:@"LoginNav"];
        [self presentViewController:loginNAV animated:YES completion:nil];
    }
}


- (IBAction)btnClickCallPhone:(id)sender
{
    NSString *strPhone = [NSString stringWithFormat:@"tel://%@",dicData[@"phone"]];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:strPhone]];
}

#pragma mark - 聊天
- (IBAction)btnClickPostMessage:(id)sender
{

    [self showSingleIconBubble:@"暂未开放此功能"];

}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
